var koa = require('koa');
var app = new koa();
var router = require('koa-router')();
const cors = require('koa2-cors');
app.use(cors());
app.use(async (ctx, next) => {
  try {
    console.log('第一次接触')
    await next();
    console.log('接触完毕，返回数据')
  } catch (err) {
    ctx.body = {

      isSuc: false,
      message: err.message
    }
  }
});
require('./router.js')(app)

// router.post('/', async function (ctx) {
	
//     ctx.body = '恭喜你成功登陆了'
// });
// router.get('/gagaga', async function(ctx){
// 	let html = `
//           <form method="POST" action="/">
//             <p>用户名</p>
//             <input name="username" type='text' /><br/>
//             <p>密码</p>
//             <input name="password" type='password' /><br/>
//             <p>邮箱</p>
//             <input name='email' /> <br />
//             <button type="submit">提交</button>
//           </form>
//         `
//         ctx.body = html
// })

// app.use(router.routes()).use(router.allowedMethods());

app.listen(3000,function(res){
    console.log('chenggong')
});
